import { createRouter, createWebHashHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'

const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView,
    meta:{title:'商城首页'}
  },
  {
    path: '/about',
    name: 'about',
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  },
  {
    path:'/login',
    name:'login',
    component:()=>import('../views/Login.vue'),
    meta:{title:'登录'}
  },
  {
    path:'/register',
    name:'register',
    component:()=>import('../views/Register.vue'),
    meta:{title:'注册'}
  },
  {
    path:'/shopcar',
    name:'shopcar',
    component:()=>import('../views/ShopCar.vue'),
    meta:{title:'购物车'}
  },
  //更多详情页面
  {
    path:'/morecar',
    name:'morecar',
    component:()=>import('../views/MoreCar.vue'),
    meta:{title:'车辆详情'}
  },
  //购买详情页面
  {
    path:'/details',
    name:'details',
    component:()=>import('../views/Details.vue'),
    meta:{title:'购买详情'}
  },
  //订单管理里页面
  {
    path:'/order',
    name:'order',
    component:()=>import('../views/Order.vue'),
    meta:{title:'订单中心'}
  }

  
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

//路由后置守卫
router.afterEach(to=>{
  document.title = to.meta.title
})

export default router
